package consultan.vanke.com.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.constraintlayout.widget.ConstraintLayout;

import butterknife.BindView;
import butterknife.OnClick;
import consultan.vanke.com.R;
import consultan.vanke.com.activity.MainActivity;
import consultan.vanke.com.utils.SimpleToolbar;

import static com.bytedance.sdk.account.open.aweme.utils.ViewUtils.getStatusBarHeight;
import static consultan.vanke.com.utils.StatusBarUtil.setPaddingTop;
import static consultan.vanke.com.utils.StatusBarUtil.setRootView;


public class BindPhoneFragment extends BaseFragment {
    @BindView(R.id.tv_fast_login)
    TextView tvFastLogin;
    private View inflate;
    private boolean isfristshow = true;
    @BindView(R.id.simple_toolbar)
    SimpleToolbar simpleToolbar;
    @BindView(R.id.simple_toolbar_main)
    ConstraintLayout simpleToolbarMain;
    @BindView(R.id.et_oldpwd)
    EditText etOldpwd;
    @BindView(R.id.et_newpwd)
    EditText etNewpwd;
    @BindView(R.id.btn_login)
    Button btnLogin;

    @Override
    protected void initViews() {
        simpleToolbar.setMainBg(getResources().getColor(R.color.white_color));
        simpleToolbar.setMainTitle("");
        simpleToolbar.setRightTitleText("账号密码登录");
    }

    @Override
    protected void initDatas() {
    }

    @Override
    protected void initEvents() {
        simpleToolbar.setLeftTitleClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pop();
            }
        });
        simpleToolbar.setRightTitleAginClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startWithPop(new LoginPwdFragment());
            }
        });
    }

    @Override
    protected View initContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        inflate = View.inflate(_mActivity, R.layout.bind_info_fragment, null);
        return inflate;
    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        ViewGroup decorView = (ViewGroup) _mActivity.getWindow().getDecorView();
        View fakeStatusBarView = new View(_mActivity);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(_mActivity) + 3);
        fakeStatusBarView.setLayoutParams(params);
        fakeStatusBarView.setBackground(getResources().getDrawable(R.drawable.bg_white));
        fakeStatusBarView.setId(android.R.id.custom);
        decorView.addView(fakeStatusBarView);
        setRootView(_mActivity, false);
        if (isfristshow) {
            setPaddingTop(_mActivity, simpleToolbar);
            isfristshow = false;
        }
        setStatusBarColors(getResources().getColor(R.color.white_color), true);
    }

    @OnClick({R.id.btn_login, R.id.tv_fast_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_login:
                Intent intent = new Intent(getActivity(), MainActivity.class);
                _mActivity.startActivity(intent);
                _mActivity.finish();
                break;
            case R.id.tv_fast_login:
                pop();
                break;
        }
    }
}
